import json

from moralis import evm_api


def get_fantomScan_data(tx_hash):
    api_key = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IjRlYTNjMzQ2LThjNTctNGNhMC05MTZjLTJlMDFlZGE3NTVkMyIsIm9yZ0lkIjoiMzc0NDYyIiwidXNlcklkIjoiMzg0ODIyIiwidHlwZUlkIjoiNDQ3MTNkYWItYmJmNy00Nzg0LThkOWUtZjZhNWEyNmYyN2FhIiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3MDYzNjA1MjUsImV4cCI6NDg2MjEyMDUyNX0.2ETgC13ITXtx6jZmb6k6hoZgt25-QnDSWNSs5ALWgUM"
    Params = {
        "chain": "fantom",
        "transaction_hash": f"0x{tx_hash}"
    }
    result = evm_api.transaction.get_transaction(
        api_key=api_key,
        params=Params
    )
    print("Fantom链数据爬取完成！")

    # json_data = json.dumps(result, indent=4)
    # with open('../../data_new/fantomdata.json', 'w', encoding='utf-8') as f:
    #     f.write(json_data)
    return result
# get_fantomScan_data("7312936a28b143d797b4860cf1d36ad2cc951fdbe0f04ddfeddae7499d8368f8")


